package _case

import (
	"gin-demo/mapper"
	"gin-demo/models"
	"gin-demo/pkg/common"
	"gin-demo/service"
	"github.com/gin-gonic/gin"
)

type caseLabelLogService struct {
	service.BaseService
}

var CaseLabelLogService caseLabelLogService

func init() {
	CaseLabelLogService = caseLabelLogService{}
}

func (caseLog caseLabelLogService) GetMapper() *mapper.CaseLabelLogMapper {
	return new(mapper.CaseLabelLogMapper)
}

// service层，处理缓存数据和数据库数据
func (caseLog caseLabelLogService) GetList(c *gin.Context) ([]models.CaseLabelLog, uint64) {
	listFilter := new(mapper.ListFilter)
	listFilter.Page = common.GetPageIndex(c)
	listFilter.Limit = common.GetPageLimit(c)
	listFilter.SerialNumber = common.GetQueryToStr(c, "serial_number")
	listFilter.SerialNumber = common.GetQueryToStr(c, "serial_number")
	listFilter.CaseId = common.GetQueryToInt(c, "case_id")
	listFilter.LabelId = common.GetQueryToStr(c, "label_id")
	listFilter.LabelName = common.GetQueryToStr(c, "label_name")
	listFilter.UserId = common.GetQueryToStr(c, "user_id")
	listFilter.StartTime = common.GetQueryToInt(c, "start_time")
	listFilter.StopTime = common.GetQueryToInt(c, "stop_time")
	return caseLog.GetMapper().GetByCondition(listFilter, []string{"id", "case_id"})
}
